//
//  DetailTableHeaderView.m
//  LvXi_newVersion
//
//  Created by 王敏 on 16/8/16.
//  Copyright © 2016年 SJT. All rights reserved.
//

#import "DetailTableHeaderView.h"
@interface DetailTableHeaderView()


@property(nonatomic,strong)UILabel * titleLabel;
@end
@implementation DetailTableHeaderView

-(id)initWithFrame:(CGRect)frame{
    if(self = [super initWithFrame:frame]){
        self.backgroundColor = [UIColor clearColor];
        
        
        UIView * containerView = [[UIView alloc] initWithFrame:CGRectMake(0, self.height - 40, self.width, 40)];
        [containerView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handeleGesture:)]];
        NSArray * colors = [NSArray arrayWithObjects:
                            (id)[RGBAColor(255, 255, 255, 0.5) CGColor],
                            (id)[RGBAColor(0,0,0,0.5) CGColor], nil];
        [containerView addGradientLayerWithColors:colors starPoint:CGPointMake(0.5, 0) endPoint:CGPointMake(0.5, 1)];
        [self addSubview:containerView];
        UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
        titleLabel.textColor = [UIColor whiteColor];
        titleLabel.font = [UIFont systemFontOfSize:14];
        titleLabel.height = 40;
        
        titleLabel.x = Ratio_Home_Width(167)+5;

        titleLabel.width = self.width - titleLabel.x - self.pullDown.width - 40;
        titleLabel.y = 0;
        [containerView addSubview:titleLabel];
        self.titleLabel = titleLabel;
        
        
        self.pullDown = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pull_down2"]];
        self.pullDown.size =CGSizeMake(20, 20);
        self.pullDown.y = 10;
        self.pullDown.x = self.width - 40;
        [containerView addSubview:self.pullDown];
    }
    return self;
}

-(void)setTitle:(NSString *)title{
    _title = title;
    self.titleLabel.text = title;
}


-(void)handeleGesture:(UITapGestureRecognizer*)gesture{
    if(self.pullDownHandle){
        self.pullDownHandle(self);
    }
}
@end
